package com.bwie.controller;

import com.bwie.pojo.Result;
import com.bwie.pojo.dto.OrderParkDto;
import com.bwie.pojo.po.OrderPark;
import com.bwie.service.OrderParkService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

@Controller
@RequestMapping("/orderPark")
public class OrderParkController {
    @Autowired
    private OrderParkService orderParkService;


    /**
     * 预约车位列表
     * @param orderParkDto
     * @return
     */
    @ResponseBody
    @GetMapping("getOrderPark")
    public PageInfo<OrderPark> getOrderPark(OrderParkDto orderParkDto){
        PageInfo<OrderPark> pageInfo = orderParkService.getOrderPark(orderParkDto);
        return pageInfo;
    }


    /**
     * 预约车位
     * @param orderPark
     * @return
     * @throws ParseException
     */
    @ResponseBody
    @PostMapping("addOrderPark")
    public Result addOrderPark(@RequestBody OrderParkDto orderPark) throws ParseException {
        orderParkService.addOrderPark(orderPark);
        return Result.success();
    }

    /**
     * 确认支付（预约车位）
     * @param orderPark
     * @return
     */
    @ResponseBody
    @PostMapping("updOrderParkType")
    public Result updOrderParkType(@RequestBody OrderPark orderPark){
        orderParkService.updOrderParkType(orderPark);
        return Result.success();
    }





    @ResponseBody
    @PostMapping("cleanOrderPark")
    public Result cleanOrderPark(@RequestBody OrderPark orderPark){
        orderParkService.cleanOrderPark(orderPark);
       return Result.success();
    }
}
